<template>
	<view class="">
		<view class="register mb24">
			<view class="back">
				<image src="../../static/login/log-left.png" mode="" @click="gotoWallet" class="leftarrow"></image>
				<view class="f17 white">{{i18n.zz}}</view>
				<navigator class="chrecord f14 grcolor" :url="'./chargerec?coin='+ coin[index1]">{{i18n.czjl}}</navigator>
			</view>
		</view>
		<view class="charege px15">
			<view class="moneybox pd15 mgt20 fsc">
				<view class="f28 uni-list-cell-db fsc white" style="width: 100%;line-height: 24px;">
					<view class="uni-input f15">{{ coin[index1] }}</view>
					<picker @change="bindPickerChange" :value="index1" :range="coin">
						<text class="f14 textcolor">
							{{i18n.xzbz}}
						<image class="ml9" src="../../static/grarrow.png" mode="" style="width: 12rpx; height: 20rpx;"></image>
						</text>
						
					</picker>
				</view>
			</view>
		</view>
		<view class="qrbox fl" >
			<view class="codebox px10 py10 bg-white">
				<tkiQrcod cid="qrcode" ref="qrcode" :val="linkUrl" onval :size="340" loadMake :showLoading="false" @result="result" class="ewm poa-center" />
			</view>
			<view class="f14 mt12 white">
				{{linkUrl}}
			</view>
			<view class="copyaddress" @click="copy(linkUrl)">
				{{i18n.fzdz}}
			</view>
		</view>
		<view class="mt35 mx15 bor5 f16 white py11 bg-theme text-c"@click="pushPage('./upload?coin='+ coin[index1])">
			{{i18n.yfksc}}
		</view>
	</view>
</template>

<script>
	import tkiQrcod from '@/components/tki-qrcode/tki-qrcode.vue';
export default {
	components:{tkiQrcod },
	data() {
		return {
			nikeName: '',
			index:0,
			list:[],
			coin:[],
			coinname:'',
			linkUrl:"",
			index1: 0,
		};
	},
	onLoad(op) {
		this.list = JSON.parse(op.coin)
		this.list.forEach((item,index)=>{
			this.coin[index] = item.coin
		})
	},
	onShow() {
		this.getWalletInfo()
	},
	computed:{
		i18n() {
			return this.$t('ecology');
		}
	},
	methods:{
		result(e) {
			this.qrImg = e;
		},
		bindPickerChange: function(e) {
			console.log('picker发送选择改变，携带值为', e.target.value);
			this.index1 =e.target.value;
			this.getWalletInfo()
		},
		async getWalletInfo(){
			let { data } = await this.$http.post('wallet.getCoinInfo', {coin:this.coin[this.index1]}, { isAuth: true, tipConfig: { isLoading: false } });
			this.linkUrl = data.coldAddress
		},
		gotoWallet(){
			uni.reLaunch({
				url:"./wallet"
			})
		},
		
	}
};
</script>

<style lang="less">
	.moneybox {
		height: 45rpx;
		opacity: 1;
		background: #121d2c;
		border-radius: 16rpx;
		margin-left: auto;
		margin-right: auto;
		image {
			width: 36rpx;
			height: 36rpx;
		}
	}
	.copyaddress{
		padding: 8rpx 18rpx;
		border: 1px solid #2474F3;
		color: #2474F3;
		border-radius: 10rpx;
		margin-top: 30rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 24rpx;
	}
.register {
	
	margin-top:60rpx;
	.back {
		justify-content: center;
		align-items: center;
		display: flex;
		font-size: 40rpx;
		margin-left: 30rpx;
		position: relative;
		.leftarrow {
			position: absolute;
			left: 0;
			top: 0;
			width: 40rpx;
			height: 40rpx;
		}
	}
	.chrecord {
		position: absolute;
		top: 4rpx;
		right:0;
		margin-right: 30rpx;
	}
}
.qrbox{
	padding-top: 50rpx;
	padding-bottom: 30rpx;
	margin-top: 30rpx;
	margin-left: auto;
	margin-right: auto;
	width: 690rpx;
	background-color:#121D2C;
}
.charege{
	margin-top: 60rpx;
	position: relative;
	image{
		width: 48rpx;
		height: 48rpx;
	}
		
}
</style>
